var t = require("../../../@babel/runtime/helpers/objectSpread2"), a = getApp();

Component({
    properties: {
        list: {
            type: Array,
            observer: "updateList"
        },
        cate_id: {
            type: String,
            observer: "updateId"
        },
        flxShow: {
            type: null
        }
    },
    data: {
        choose_index: 1,
        category_index: 0,
        sort: {
            up: 0,
            down: 0
        },
        id: "",
        search_type: 0,
        order_type: 0,
        goods_list: []
    },
    methods: {
        updateId: function() {
            var t = this.data.cate_id;
            t && this.setData({
                id: t
            });
        },
        updateList: function() {
            var t = this.data.list;
            t && 0 !== t.length && this.setData({
                goods_list: t
            });
        },
        choose: function(t) {
            var a = t.currentTarget.dataset.index;
            this.setData({
                choose_index: a
            }), 1 !== a ? 0 == this.data.sort.up && 0 == this.data.sort.down ? this.setData({
                "sort.up": 1,
                "sort.down": 0
            }) : 1 == this.data.sort.up && 0 == this.data.sort.down ? this.setData({
                "sort.up": 0,
                "sort.down": 1
            }) : 0 == this.data.sort.up && 1 == this.data.sort.down && this.setData({
                "sort.up": 1,
                "sort.down": 0
            }) : 1 == a && this.setData({
                "sort.up": 0,
                "sort.down": 0
            }), 1 == this.data.sort.down ? this.setData({
                order_type: 1
            }) : this.setData({
                order_type: 0
            });
            var s = a - 1;
            this.setData({
                search_type: s
            });
            var e = {
                page: 1,
                order_type: this.data.order_type,
                search_type: s,
                cate_id: this.data.id
            };
            this.getData(e);
        },
        getData: function(s) {
            var e = this;
            a._getNetWork({
                url: a.getNetAddresss("plugin.tiktok-cps.api.goods.good-list"),
                data: s,
                success: function(r) {
                    var o = r.data;
                    if (0 == o.result) return a.tips(o.msg);
                    e.setData({
                        goods_list: o.data.products
                    }), e.triggerEvent("updateCategoryData", t(t({}, s), {}, {
                        total_page: o.data.last_page,
                        list: o.data.products
                    }));
                }
            });
        },
        link_detail: function(t) {
            var a = t.currentTarget.dataset.id;
            wx.navigateTo({
                url: "/packageF/cps/detail/detail?goods_id=" + a
            });
        }
    }
});